package com.laf.manage.domain.query;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;

@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "动态查询参数")
public class DynamicQuery extends PageQuery{

    @ApiModelProperty(value = "关键字")
    private String keyword;

    @ApiModelProperty(value = "标签")
    private List<Long> tagIds;

    @ApiModelProperty(value = "用户id" , hidden = true)
    private Long createUserId;

    @ApiModelProperty(value = "审核状态" )
    private Integer verifyStatus;


    /** 请求参数 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    @TableField(exist = false)
    private Map<String, Object> params;

    public LocalDateTime getBeginTime()
    {
        if (params!= null && params.get("beginTime")!=null ){
            return LocalDateTime.parse(params.get("beginTime").toString(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        }
        return null;
    }

    public LocalDateTime getEndTime()
    {
        if (params!= null && params.get("endTime")!=null ){
            return LocalDateTime.parse(params.get("endTime").toString(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        }
        return null;
    }


}
